package com.idm.tacacs.utils;

import java.sql.Connection;
import java.sql.DriverManager;

public class TacacsDao {

	/**
	 * Method : createConnection()
	 *
	 * Method create connection specific to MSSQL based on the Provided 
	 * DataSource Name that is provided as arguement.
	 *
	 * @param String connectionType
	 * @return Connection
	 * @exception TacacsException
	 */

	public static Connection createConnection(String connectUrl) 
	throws TacacsServiceException , TacacsException
	{
		Connection objConnection = null;
		String strMethodName = null;
		String strDataSource = null;
		try{
			if(connectUrl != null)
			{
				Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
				String dbserver = "jdbc:sybase:Tds:STPLT1795:5000";
				String dbname = "sa";
				String password = "";
				System.out.println("dbserver "+dbserver);
				System.out.println(" dbname "+dbname);
				System.out.println("password "+password);
				objConnection = DriverManager.getConnection(dbserver, dbname, password);
			}

		}
		catch(Exception e)
		{
			System.out.println(e.toString());
			throw new TacacsException(e);		
		}
		return objConnection;
	}

}
